
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Canvas;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.Panel;
import java.awt.TextField;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionAdapter;
import java.awt.event.MouseMotionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/
public class Ejemplo2 {

 public void mo() {
        Frame f=new Frame();
        Label l1=new Label("X=");
        Label l2=new Label("Y=");
        final TextField t1=new TextField(                );
        final TextField t2=new TextField(                );
        Panel p1=new Panel();
        Panel p2=new Panel();
        Panel p3=new Panel();
        Panel p4=new Panel();
        //Panel p5=new Panel();
        Panel centro=new Panel();

        // b=new Dibujo();
        

        p2.setLayout(new FlowLayout());
        p2.add(l1);
        p2.add(t1,BorderLayout.EAST);
        p2.add(l2);
        p2.add(t2,BorderLayout.WEST);

        p3.addMouseMotionListener(new MouseMotionAdapter() {

           
            public void mouseMoved(MouseEvent e) {
             t1.setText(e.getX()+" ");
             t2.setText(e.getY()+"");
             //e.getY();
             
            }
        });


     


        f.add(p1);
        f.add(p3);
        f.add(p2);
        f.setLayout(new GridLayout(3, 1));

          f.addWindowListener(new WindowAdapter() {

            @Override
         public void windowClosing(WindowEvent e) {
                System.exit(0);
            }


        });
       
       
        f.setVisible(true);
        f.setSize(400, 400);






    }
  class Dibujo extends Canvas{
    private int x1;
    private int y1;
    private int x2;
    private int y2;
    private int clicks;

        @Override
    public void paint(Graphics g){
        if(clicks==1){
            g.drawOval(x1-10, y1-10, 20, 20);
        }else{
            g.drawOval(x1-10, y1-10, 20, 20);
            g.drawLine(x1, y1, x2, y2);

        }
    }

    public void addPunto(int x,int y){
        clicks++;
        if(clicks==1){
            this.x1==x;
            this.y1==y;

        }else{
            this.x2==x;
            this.y2==y;
            clicks==0;
        }
        repaint();


    }
    }
    public static void main(String args[]){
        Ejemplo2 ejem=new Ejemplo2();
        ejem.mo();
        
    }
}
